package com.ssm.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.blog.dao.MoodDAO;
import com.ssm.blog.pojo.Diary;
import com.ssm.blog.pojo.Mood;
import com.ssm.blog.pojo.criteria.MoodCriteria;
import com.ssm.blog.service.MoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MoodServiceImpl implements MoodService {
    @Autowired
    private MoodDAO moodDAO;

    @Override
    public void addMood(Mood mood) {
        moodDAO.addMood(mood);
    }

    @Override
    public PageInfo<Mood> getMoodList(MoodCriteria criteria, int pageNo, int pageSize) {
        PageHelper.startPage(pageNo, pageSize, "id desc");
        List<Mood> moodList = moodDAO.getMoodList(criteria);
        PageInfo<Mood> pageInfo = new PageInfo<>(moodList);
        return pageInfo;
    }

    @Override
    public void deleteMood(int id) {
        moodDAO.deleteMood(id);
    }
}
